package tour.spring.bc.dao.impl;

import java.util.Collection;
import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Repository;

import tour.spring.bc.dao.TourDao;
import tour.spring.bc.model.Reservation;
import tour.spring.bc.model.Tour;

@Repository
public class TourDaoImpl extends AbstractDAOImpl<Tour> implements
		TourDao {

	public TourDaoImpl() {
		super(Tour.class);
	}

	@Override
	public Collection<Tour> searchToursByDatesAndPlace(Date dateFrom, Date dateTo, Collection<Long> placesId) {
		 
		List<Tour> tours = loadByNamedParam("SELECT t FROM Tour t WHERE t.hotel.place.id IN ( :param )", "param", placesId);
		return tours;
	}
	
	public String searchTourDescriptionById(Long tourId) {
		
		
		List<Tour> descriptions = loadByNamedParam("SELECT t FROM Tour t WHERE t.id = :param", "param", tourId);
		if(descriptions.isEmpty()){
			return null;
		}
		return descriptions.get(0).getDescription();
	}

}
